<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>拖拽</title>
    <style>
        div {
            width: 100px;
            height: 50px;
            background-color: pink;
            cursor: col-resize;
        }
    </style>
</head>

<body>

    <div id="box">

    </div>
    <script>
        box.onmousedown = function (e) {
            let _this = this
            
            document.onmousemove = function (e) {
                _this.style.width = 100 + e.clientX +'px'
            }

            document.onmouseup = function() {
                this.onmousemove = null
                this.onmouseup = null
            }
            console.log(e.clientX)

    }


    </script>
</body>

</html>